<template>
  <!--  todo 嵌入搜索-->
  <uni-collapse accordion v-model="accordionVal">
    <uni-collapse-item :title="item.title" v-for="(item, index) in groupList" :key="index">
      <view class="content">
        <uv-list v-for="pwdInfo in item.pwdList" :key="pwdInfo.id" @click="toPwdInfo(pwdInfo)">
          <uv-list-item :title="pwdInfo.title"></uv-list-item>
        </uv-list>
      </view>
    </uni-collapse-item>

  </uni-collapse>
</template>

<script setup lang="ts">
//
import { onMounted, ref } from 'vue'
import { useDataStore } from '@/stores/modules/data'

const accordionVal = ref('-1')
const dataStore = useDataStore()
const groupList = ref<PwdGroup[]>([])

onMounted(() => {
  console.log('index onMounted')
  groupList.value = dataStore.getGroupList()
  console.log(groupList.value)
})

function toPwdInfo(pwdInfo: PwdInfo) {
  console.log('toDetail', pwdInfo)
  dataStore.setCurPwdInfo(pwdInfo)
  uni.navigateTo({
    url: '/pages/pwdinfo/pwdinfo',
  })
}
</script>

<style lang="scss">
//
</style>
